//Sets the index and table back to the first row
function first() {
    setIndex(1);
    setIndexOf();
    printTable(1);
}
//Sets the index and table back to the last row
function last() {
    setIndex(getSize());
    setIndexOf();
    printTable(getSize());
}

function atOfLowerBound(index) {
    if (index == 1) {
        return 1;
    } else {
        return 0;
    }
}

function atOfUpperBound(index) {
    if (index == getSize()) {
        return 1;
    } else {
        return 0;
    }
}

//Gets previous row if not at lower bound
function decrement() {
    var curInd = getCurrentIndex();
    if (atOfLowerBound(curInd) == 0) {
        curInd--;
        setIndex(curInd);
        setIndexOf();
        printTable(curInd);
    }
}

//Gets next row if not at upper bound
function increment() {
    var curInd = getCurrentIndex();
    if (atOfUpperBound(curInd) == 0) {
        curInd++;
        setIndex(curInd);
        setIndexOf();
        printTable(curInd);
    }
}

//Sets the current Index
function setIndex(curInd) {
    document.getElementById("currentIndex").innerHTML = curInd;
}

//Reads current index
function getCurrentIndex() {
    return document.getElementById("currentIndex").innerHTML;
}

//Sets the "Index _ of _" field in the HTML
function setIndexOf() {
    document.getElementById("indexOf").innerHTML = "Index " + getCurrentIndex() + " of " + getSize();
}
